/* retarded code */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define I_EMPTY		00	/* '.' */
#define I_BUSY		01	/* '*' */
#define I_SOURCE	02	/* 'X' */

#define O_EMPTY		010			/* '.' */
#define O_L_FW		020			/* '/' */
#define O_L_BK		040			/* '\' */

#define O_L_BOTH	(O_L_FW | O_L_BK)	/* 'X' */

#define N_MAX 100
#define M_MAX 100

typedef struct pos { int y, x; } dot_pos_t;

int map[N_MAX][M_MAX];



void
print_map(FILE* fp, int n, int m)
{
	int i, j;
	extern int map[N_MAX][M_MAX];
	for (i = 0; i < n; ++i) {
		for (j = 0; j < m; ++j) {
			if (map[i][j] & O_L_FW && map[i][j] & O_L_BK)
				putc('X', fp);
			else if (map[i][j] & O_L_FW)
				putc('/', fp);
			else if (map[i][j] & O_L_BK)
				putc('\\', fp);
			else if (map[i][j] & I_BUSY)
				putc('*', fp);
			else
				putc('.', fp);
		}
		putc('\n', fp);
	}
}


void
mktrace(int n, int m, dot_pos_t source, dot_pos_t dir)
{
	unsigned char boolean = false;
	extern int map[N_MAX][M_MAX];
	int i = source.y, j = source.x;
	for (/* vars are initialized */;
	      i < n && i >= 0 && j < m && j >= 0 ; )
	      {
		if ( (j + dir.x < m || j + dir.x >= 0) && /* check if we have some space */
		     (i + dir.y < n || i + dir.y >= 0) )
		     {
			if (map[i][j] & I_BUSY) { /* light cannot go further */
				return; /* never reached */
			} else if ( (map[i + dir.y][j] & I_BUSY) && (map[i][j + dir.x] & I_BUSY) ) { /* light cannot go further */
				map[i][j] |= (dir.y / dir.x == -1) ? O_L_FW : O_L_BK;
				return;
			}
			else if ( (map[i + dir.y][j + dir.x] & I_BUSY) && ( (map[i + dir.y][j] & I_BUSY) /* light reflects from blocks */
			                                                 || (map[i][j + dir.x] & I_BUSY) ) ) {
				if (map[i][j + dir.x] & I_BUSY) {
					map[i][j] |= (dir.y / dir.x == -1) ? O_L_FW : O_L_BK;
					boolean = true;
					dir.x *= -1;
					i += dir.y;
				} else if (map[i + dir.y][j] & I_BUSY) {
					map[i][j] |= (dir.y / dir.x == -1) ? O_L_FW : O_L_BK;
					boolean = true;
					dir.y *= -1;
					j += dir.x;
				}
			} else if (i == 0 && dir.y == -1 || i == n-1 && dir.y == 1) { /* light reflects from walls (top and bottom) */
				map[i][j] |= (dir.y / dir.x == -1) ? O_L_FW : O_L_BK;
				boolean = true;
				dir.y *= -1;
				j += dir.x;
				if (map[i][j] & ( (dir.y / dir.x == -1) ? O_L_FW : O_L_BK ) && boolean)
					return; /* trajectory was already 'traced' => BE DONE NOW */
			} else if (j == 0 && dir.x == -1 || j == m-1 && dir.x == 1) { /* ... (left and right) */
				map[i][j] |= (dir.y / dir.x == -1) ? O_L_FW : O_L_BK;
				boolean = true;
				dir.x *= -1;
				i += dir.y;
			} else {
				if ( (map[i][j] & ( (dir.y / dir.x == -1) ? O_L_FW : O_L_BK )) && /* light remains untouched */
				     (map[i+dir.y][j+dir.y] & ( (dir.y / dir.x == -1) ? O_L_FW : O_L_BK )) &&
				     boolean )
					return; /* trajectory was already 'traced' => BE DONE NOW */
				map[i][j] |= (dir.y / dir.x == -1) ? O_L_FW : O_L_BK;
				boolean = true;
				i += dir.y;
				j += dir.x;
			}
		} else {
			map[i][j] |= (dir.y / dir.x == -1) ? O_L_FW : O_L_BK;
			/* i += dir.y;
			   j += dir.x; */
			return; /* inside of 'for' */
		}
#ifdef DEBUG
		usleep((useconds_t) 400000);
		print_map(stderr, n, m);
		(void)fprintf(stderr, "\n---------------------\n");
#endif /* #ifdef DEBUG */
	}
	return; /* outterspace */
}


int
main(void)
{
	extern int map[N_MAX][M_MAX];
	int n, m;
	int i = 0, j = 0;
	dot_pos_t source_pos = { 0, 0 };
	dot_pos_t direction[4] = { {-1, -1}, {-1, 1} , {1, -1}, {1, 1} };
	char c;

	freopen("light.in", "r", stdin);
	freopen("light.out", "w", stdout);

	scanf("%d %d\n", &n, &m);
	while (i < n) {
		j = 0;
		while (j < m) {
			if (c = getchar(), (c == '\n' || c == EOF))
				continue;

			if      (c == '.')
				map[i][j] = I_EMPTY | O_EMPTY;
			else if (c == '*')
				map[i][j] = I_BUSY;
			else if (c == 'X') {
				map[i][j] = I_SOURCE;
				source_pos.y = i;
				source_pos.x = j;
			}
			++j;
		}
		++i;
	}

	for (i = 0; i < 4; ++i) {
		mktrace(n, m, source_pos, direction[i]);
#ifdef DEBUG
		usleep((useconds_t) 100000);
#endif /* DEBUG */
	}

	map[source_pos.y][source_pos.x] |= O_L_BOTH;

	print_map(stdout, n, m);
	return 0;
}
